package org.codehaus.janino.util.resource;

import org.codehaus.janino.Resource;

/**
 * This class specializes the {@link org.codehaus.janino.util.resource.ResourceFinder}
 * for finding resources in {@link java.io.File}s. <p> It finds {@link FileResource}s
 * instead of simple
 * {@link Resource}s.
 */
public abstract class FileResourceFinder extends ResourceFinder {

    public final Resource findResource(String resourceName) {
        
        String file = this.findResourceAsFile(resourceName);
        
        if (file == null) {
            return null;
        }
        
        return new FileResource(file);
    }

    /**
     * Converts a given resource resource name into a {@link File}.
     */
    protected abstract String findResourceAsFile(String resourceName);
}
